using cin and cout in textmate [migrated]
Posted
by
That Guy
on Programmers
See other posts from Programmers
or by That Guy
Published on 2011-11-20T16:10:16Z
Indexed on
2011/11/20
18:24 UTC
Read the original article
Hit count: 430
I am usually a Java programmer, and have used textmate for that almost exclusively, but lately I started using C++ with it. but when i use even the most basic programs and incorporate the cin keyword, and run the program, I dont get an oppurtunity to put in anything during runtime and sometimes it inserts random values by itself! for example, if i ran this in textmate:
#include <iostream>
int stonetolb(int);
int main() {
using namespace std;
int stone;
cout << "enter the weight in stone";
cin >> stone;
int pounds = stonetolb(stone);
cout << stone << "stone = ";
cout << pounds <<" pounds.";
return 0;
}
int stonetolb(int sts) {
return 14 * sts;
}
I would come out with the output:
enter the weight in stone32767stone = 458738 pounds.
Why is this happening, and how do I stop it?
© Programmers or respective owner